# -*- coding:utf-8 -*-
import unittest
import HTMLTestRunner


def get_test_cases(dirpath):
    test_cases = unittest.TestSuite()
    suites = unittest.defaultTestLoader.discover(dirpath, 'Test*.py', top_level_dir=dirpath)
    for suite in suites:
        test_cases.addTests(suite)
    return test_cases

if __name__ == '__main__':
    cases = get_test_cases('testcases')
    filename = 'report/testReport.html'  # 设置报告文件名
    f = file(filename, 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(stream=f, title=u'Data Driver Test Demo', description=u'详细测试结果如下:')
    runner.run(cases)